package com.ctgu.chatapp.model.Dao

import androidx.room.Dao
import androidx.room.Insert
import androidx.room.Query
import com.ctgu.chatapp.model.pojo.Request
import com.ctgu.chatapp.showPojo.FriendQuest
import kotlinx.coroutines.flow.Flow

@Dao
interface RequestDao {
    @Query("select Request.touId,Information.nickName,Information.profile,Information.motto,Request.state from Request left join Information on Request.touId = Information.chatID where Request.uid = :chatID order by Request.id desc")
    fun getFriendRequest(chatID: Long): Flow<List<FriendQuest>>

    @Insert
    fun addFriendRequest(request: Request)

    @Query("update Request set state = :state where uid = :uid and touId = :touId")
    fun updateFriendRequest(state: Int, uid: Long, touId: Long)

    @Query("select touId from Request where uid = :uid")
    fun queryAllRequestUid(uid: Long): Flow<List<Long>>
}